package joe.works.cacheimpl;

import java.util.List;

import joe.works.commons.IDataLoader;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * An implementation of {@link IDataLoader} which loads a list from a configured sql-map
 * @author josseyj
 *
 * @param <Type>
 */
public class SqlMapListLoader<Type> extends SqlMapClientDaoSupport implements IDataLoader<List<Type>> {

	private String sqlMapName;
	private Object parameter;
	
	public void setSqlMapName(String sqlMapName) {
		this.sqlMapName = sqlMapName;
	}
	
	public void setParameter(Object parameter) {
		this.parameter = parameter;
	}
	
	@SuppressWarnings("unchecked")
	public List<Type> loadData() {
		return getSqlMapClientTemplate().queryForList(sqlMapName, parameter);
	}

}
